﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using yncTech.BusinessObjects;
using EntitySpaces.Interfaces;

public partial class Admin_Sys_Dic_Dic_ThirdUnit_FirstFloor : AdminBasePage
{
    protected decimal? tunitID;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            tunitID = decimal.Parse(Request.QueryString["id"]);
        }
    }
    protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
    {
        //decimal Id = ;
        BFThirdUnitCabinQuery q1 = new BFThirdUnitCabinQuery("q1");    
        //BFThirdUnitCollection units = new BFThirdUnitCollection();
        //units.LoadAll();
        q1.Where(q1.ThirdUnitID == tunitID);
        q1.Load();
        pageGrid.DataSource = q1.LoadDataTable();
        pageGrid.CurrentPage = e.NewPageIndex;
        pageGrid.DataBind();
    }
    protected void Delete_Bf(object sender, CommandEventArgs e)
    {
        decimal Id = decimal.Parse(e.CommandArgument.ToString());
        using (esTransactionScope tr = new esTransactionScope())
        {
            BFThirdUnitCabinCollection q1 = new BFThirdUnitCabinCollection();
            q1.Query.Where(q1.Query.ThirdUnitID == Id);
            q1.Query.Load();
            q1.MarkAllAsDeleted();
            q1.Save();
            tr.Complete();
            FinLend finLend = new FinLend();
            finLend.LoadByPrimaryKey(Id);
            if (finLend.es.HasData)
            {
                finLend.LendStatus = "LendStatus000";
                finLend.Save();
                ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showMsg()", true);
            }
        }
    }
}